# Maintainer: Levente Polyak <anthraxx[at]archlinux[dot]org>

pkgname=diffoscope
pkgver=241
pkgrel=1
pkgdesc='Tool for in-depth comparison of files, archives, and directories'
url='https://diffoscope.org/'
arch=('loong64' 'x86_64')
license=('GPL3')
depends=('python-magic' 'python-libarchive-c' 'python-distro' 'python-defusedxml'
         'python-tlsh')
optdepends=(
  'acl: access control list utilities support'
  'binutils: binary utilities support'
  'binwalk: binwalk support'
  'bzip2: bzip2 utilities support'
  'cdrtools: ISO utilities support'
  'colord: ICC profiles support'
  'cpio: cpio archive support'
  'diffutils: diff utilities support'
  'docx2txt: docx comparing support'
  'dtc: device tree comparing support'
  'e2fsprogs: Ext2/3/4 filesystem utilities support'
  'enjarify: Android dex file support'
  'hdf5: Hierarchical Data Format support'
  'imagemagick: ImageMagick identify support'
  'fpc: Free Pascal utilities support'
  'java-environment: java utilities support'
  'libcaca: image compare support'
  'libxmlb: binary XML blobs support'
  'llvm: LLVM bitcode files support'
  'lz4: lz4 compression support'
  'odt2txt: odt comparing support'
  'fontforge: bitmap font utilities support'
  'gettext: GNU internationalization utilities support'
  'ghc: haskell utilities support'
  'giflib: gifbuild utilities support'
  'gnupg: GNU privacy guard support'
  'gnumeric: GNOME Spreadsheet support'
  'mono: mono support'
  'openssh: OpenSSH key comparing support'
  'openssl: .p7c and .p7b certificates. support'
  'pgpdump: PGP files support'
  'poppler: PDF utilities support'
  'r: R language support'
  'radare2: decompiler for executables'
  'sqlite: SQLite support'
  'squashfs-tools: squashfs filesystem support'
  'python-guestfs: guestfs filesystem support'
  'python-argcomplete: completion support'
  'python-jsbeautifier: javascript beautifier support'
  'python-progressbar: show progressbar support'
  'tcpdump: pcap matching support'
  'uboot-tools: FIT image support'
  'unzip: zip utilities support'
  'gzip: gzip utilities support'
  'tar: tar utilities support'
# 'wabt: webassembly support' unittest fails
  'xxd: xxd utilities support'
  'xz: XZ and LZMA utilities support'
  'zstd: zst compression'
)
makedepends=('help2man' 'python-docutils' 'git' 'python-setuptools')
checkdepends=(
  'python-pytest' 'python-jsbeautifier' 'python-h5py' 'acl' 'binutils' 'bzip2' 'cdrtools' 'cpio' 'diffutils' 'e2fsprogs' 'enjarify'
  'hdf5' 'imagemagick' 'java-environment=11' 'fontforge' 'gettext' 'ghc' 'gnupg' 'mono' 'pgpdump' 'poppler' 'sqlite' 'squashfs-tools'
  'libxmlb' 'lz4' 'unzip' 'gzip' 'tar' 'tcpdump' 'vim' 'xz' 'llvm' 'colord' 'fpc' 'openssh' 'openssl' 'odt2txt' 'docx2txt' 'r' 'dtc'
  'giflib' 'gnumeric' 'python-progressbar' 'binwalk' 'python-argcomplete' 'zstd' 'uboot-tools')
source=(https://diffoscope.org/archive/diffoscope-${pkgver}.tar.bz2{,.asc})
sha512sums=('b10838f9af06d59dac38360c3e0510fb818921e896eab22e525363cc09459531c28a594772fbdd61a1b05cbd291092ee194bd45bfaaa83421893b205a4ef454f'
            'SKIP')
b2sums=('331381287d7fb7eac1d9d60e0082bb4d701ecf4356c047666b68bcb687b368236cd70639ceb0532173c4ca5ca97f39a95e95e48e12d839556da363f1efd611d7'
        'SKIP')
validpgpkeys=("C2FE4BD271C139B86C533E461E953E27D4311E58"
              "66AE2B4AFCCF3F52DA184D184B043FCDB9444540")
              # Mattia Rizzolo <mattia@mapreri.org>
              # Chris Lamb <chris@chris-lamb.co.uk>

build() {
  cd ${pkgname}-${pkgver}
  python setup.py build
  make -C doc
}

check() {
  cd ${pkgname}-${pkgver}
  # lcms2 causes cd-iccdump to segfault
  rm tests/comparators/test_icc.py
  PYTHONPATH=".:${PYTHONPATH}" PYTHONDONTWRITEBYTECODE=1 py.test \
    -k 'not test_ppu and not test_superblock '
    # unsquashfs output differs from fixture.
    # ppu bug https://salsa.debian.org/reproducible-builds/diffoscope/issues/9
}

package() {
  cd ${pkgname}-${pkgver}
  python setup.py install --skip-build -O1 --root="${pkgdir}"
  install -Dm 644 README.rst -t "${pkgdir}/usr/share/doc/${pkgname}"
  install -Dm 644 doc/diffoscope.1 -t "${pkgdir}/usr/share/man/man1"
}

# vim: ts=2 sw=2 et:
